package com.ali.sofa.util;

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.lang.annotation.Annotation;

public class LinuxSystem implements Condition {

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
        ConfigurableListableBeanFactory configurableListableBeanFactory = conditionContext.getBeanFactory();

        var environment = conditionContext.getEnvironment();

        ClassLoader classLoader = conditionContext.getClassLoader();

        //获取bean定义的注册类
        var beanDefinitionRegistry = conditionContext.getRegistry();

        //判断是否注册了某个bean
        beanDefinitionRegistry.containsBeanDefinition("person");

        String property = environment.getProperty("os.name");


        if(property.contains("Mac")){
            return true;
        }


        return false;

    }
}
